﻿//********************************************************************************//
//创建日期：<创建日期，2017-08-29>
//创建作者：<郭登杰，guodengjie@shanghai3h.com>
//功能说明：账单信息Model
//********************************************************************************//
using System;
using System.Collections.Generic;
using YXYLCommon;
using System.Data;

namespace Entity
{
    [Serializable]
    /// <summary>
    /// 发票库存
    /// </summary>
    public class YSSFZhangDanXX : BaseModel
    {
        public YSSFZhangDanXX()
        {
          
        }

        public string S_FAPIAOHM { get; set; }
        public string S_DAYINR { get; set; }
        public string S_YONGHUH { get; set; }
        public string S_YONGHUM { get; set; }
        public string S_KAIHUHM { get; set; }
        public string S_SHOUFEIFS { get; set; }
        public string S_KAIHUYH { get; set; }
        public string S_KAIHUZH { get; set; }
        public string S_JJJE { get; set; }
        public string S_YOUBIAN { get; set; }
        public string S_DIZHI { get; set; }
        public string S_YEWUSLBM { get; set; }
        public string S_YWY { get; set; }
        public string S_YEWUSLBMDH { get; set; }
        public string S_JIAOFEIR { get; set; }

        public DbInt I_FEIYONGBH { get; set; }
        public DbInt I_ZHUANGTAI { get; set; }
        public DbInt I_JLZT { get; set; }
        public DbInt I_JHL { get; set; }
        public DbInt I_SYL { get; set; }
        public DbInt I_JJL { get; set; }
        public DbInt I_YM { get; set; }
        public DbInt I_YWY { get; set; }

        public DbDecimal N_JJJE { get; set; }
        public DbDateTime D_DAYINRQ { get; set; }
        public DbDateTime D_KAIPIAORQ { get; set; }

        public override BaseModel ToObject(System.Data.DataRow row)
        {
            this.IsExists = true;
            this.S_DAYINR = row.Table.Columns.Contains("S_DAYINR") ? Convert.ToString(row["S_DAYINR"]) : null;
            this.S_DIZHI = row.Table.Columns.Contains("S_DIZHI") ? Convert.ToString(row["S_DIZHI"]) : null;
            this.S_FAPIAOHM = row.Table.Columns.Contains("S_FAPIAOHM") ? Convert.ToString(row["S_FAPIAOHM"]) : null;
            this.S_JIAOFEIR = row.Table.Columns.Contains("S_JIAOFEIR") ? Convert.ToString(row["S_JIAOFEIR"]) : null;
            this.S_JJJE = row.Table.Columns.Contains("S_JJJE") ? Convert.ToString(row["S_JJJE"]) : null;
            this.S_KAIHUHM = row.Table.Columns.Contains("S_KAIHUHM") ? Convert.ToString(row["S_KAIHUHM"]) : null;
            this.S_KAIHUYH = row.Table.Columns.Contains("S_KAIHUYH") ? Convert.ToString(row["S_KAIHUYH"]) : null;
            this.S_KAIHUZH = row.Table.Columns.Contains("S_KAIHUZH") ? Convert.ToString(row["S_KAIHUZH"]) : null;
            this.S_SHOUFEIFS = row.Table.Columns.Contains("S_SHOUFEIFS") ? Convert.ToString(row["S_SHOUFEIFS"]) : null;
            this.S_YEWUSLBM = row.Table.Columns.Contains("S_YEWUSLBM") ? Convert.ToString(row["S_YEWUSLBM"]) : null;
            this.S_YEWUSLBMDH = row.Table.Columns.Contains("S_YEWUSLBMDH") ? Convert.ToString(row["S_YEWUSLBMDH"]) : null;
            this.S_YONGHUH = row.Table.Columns.Contains("S_YONGHUH") ? Convert.ToString(row["S_YONGHUH"]) : null;
            this.S_YONGHUM = row.Table.Columns.Contains("S_YONGHUM") ? Convert.ToString(row["S_YONGHUM"]) : null;
            this.S_YOUBIAN = row.Table.Columns.Contains("S_YOUBIAN") ? Convert.ToString(row["S_YOUBIAN"]) : null;
            this.S_YWY = row.Table.Columns.Contains("S_YWY") ? Convert.ToString(row["S_YWY"]) : null;

            this.I_FEIYONGBH = row.Table.Columns.Contains("I_FEIYONGBH") ? DbInt.Parse(row["I_FEIYONGBH"]) : DbInt.Parse(null);
            this.I_JHL = row.Table.Columns.Contains("I_JHL") ? DbInt.Parse(row["I_JHL"]) : DbInt.Parse(null);
            this.I_JJL = row.Table.Columns.Contains("I_JJL") ? DbInt.Parse(row["I_JJL"]) : DbInt.Parse(null);
            this.I_JLZT = row.Table.Columns.Contains("I_JLZT") ? DbInt.Parse(row["I_JLZT"]) : DbInt.Parse(null);
            this.I_SYL = row.Table.Columns.Contains("I_SYL") ? DbInt.Parse(row["I_SYL"]) : DbInt.Parse(null);
            this.I_YM = row.Table.Columns.Contains("I_YM") ? DbInt.Parse(row["I_YM"]) : DbInt.Parse(null);
            this.I_YWY = row.Table.Columns.Contains("I_YWY") ? DbInt.Parse(row["I_YWY"]) : DbInt.Parse(null);
            this.I_ZHUANGTAI = row.Table.Columns.Contains("I_ZHUANGTAI") ? DbInt.Parse(row["I_ZHUANGTAI"]) : DbInt.Parse(null);

            this.N_JJJE = row.Table.Columns.Contains("N_JJJE") ? DbDecimal.Parse(row["N_JJJE"]) : DbDecimal.Parse(null);

            this.D_DAYINRQ = row.Table.Columns.Contains("D_DAYINRQ") ? DbDateTime.Parse(row["D_DAYINRQ"]) : DbDateTime.Parse(null);
            this.D_KAIPIAORQ = row.Table.Columns.Contains("D_KAIPIAORQ") ? DbDateTime.Parse(row["D_KAIPIAORQ"]) : DbDateTime.Parse(null);
            return this;
        }
    }
    public class DALYSSFZhangDanXX : BaseDAL
    {
        public DALYSSFZhangDanXX()
        {

        }
        protected override void fillSaveProc(BaseModel model)
        {
            
        }

        public List<YSSFZhangDanXX> Get(int type, string yonghuh, int y1, int y2,int sffs)
        {
            dbProc.Init("P_YSSF_DAYINZDXXHQ");
            dbProc.AddParameter("V_TYPE",type);
            dbProc.AddParameter("V_YONGHUH", yonghuh);
            dbProc.AddParameter("V_Y1", y1);
            dbProc.AddParameter("V_Y2", y2);
            dbProc.AddParameter("V_SFFS", sffs);
            return CommonService.Ini().GetList<YSSFZhangDanXX>(dbProc);
        }
        /// <summary>
        /// 获取已打印账单信息
        /// </summary>
        /// <param name="zt">打印状态 0:全部 1:成功 2:打坏</param>
        /// <param name="ym">水量年月</param>
        /// <param name="hm">发票或费用编号</param>
        /// <param name="printdate">打印日期</param>
        public List<YSSFZhangDanXX> Get2(int zt, int ym, string hm, DbDateTime printdate)
        {
            dbProc.Init("P_YSSF_DAYINZDXXHQ2");
            dbProc.AddParameter("V_ZHUANGTAI", zt);
            dbProc.AddParameter("V_YM", ym);
            dbProc.AddParameter("V_HM", hm);
            dbProc.AddParameter("V_PRINTDATE", printdate.TimeDBParameter);
            return CommonService.Ini().GetList<YSSFZhangDanXX>(dbProc);
        }
        public DbCmdResult DY(int dyzt,int sffs,int zdbh,string fphms,string yhh,string yhm,string khhm,DbDateTime dyrq,int dyr,string dyrname)
        {
            dbProc.Init("P_YSSF_JJZD_DY");
            dbProc.AddParameter("V_TYPE", dyzt);
            dbProc.AddParameter("V_SFFS", sffs);
            dbProc.AddParameter("V_ZHANGDANBH", zdbh);
            dbProc.AddParameter("V_FAPIAOHM", fphms);
            dbProc.AddParameter("V_YONGHUH", yhh);
            dbProc.AddParameter("V_YONGHUM", yhm);
            dbProc.AddParameter("V_KAIHUHM", khhm);
            dbProc.AddParameter("V_DAYINRQ", dyrq.TimeDBParameter);
            dbProc.AddParameter("V_IDAYINR", dyr);
            dbProc.AddParameter("V_DAYINR", dyrname);
            return CommonService.Ini().ExcuteProcOracle(dbProc);
        }
        /// <summary>
        /// 发票打印状态变更
        /// </summary>
        /// <param name="zt">1:成功  2:打坏 0:未打印</param>
        /// <param name="fphms">发票号码s</param>
        public DbCmdResult DaYinZTBG(int zt, string fphms)
        {
            dbProc.Init("P_YSSF_ZDDYZTBG");
            dbProc.AddParameter("V_ZHUANGTAI", zt);
            dbProc.AddParameter("V_FAPIAOHMS", fphms);
            return CommonService.Ini().ExcuteProcOracle(dbProc);
        }
        public List<QSSFZhangDanDYTJ> DaYinTJGet(DbDateTime printdate)
        {
            dbProc.Init("P_YSSF_ZDDYTJ");
            dbProc.AddParameter("V_PRINTDATE", printdate.TimeDBParameter);
            return CommonService.Ini().GetList<QSSFZhangDanDYTJ>(dbProc);
        }
    }

}